/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JInternalFrameeditdetailsalesbill.java
 *
 * Created on Dec 13, 2011, 10:22:07 PM
 */
package callcenter;

import Database.DetailSalesBill;
import Database.Product;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author user
 */
public class JInternalFrameeditdetailsalesbill extends javax.swing.JInternalFrame {

    /** Creates new form JInternalFrameeditdetailsalesbill */
    Vector<Product> pdl=new Vector<Product>();
    public JInternalFrameeditdetailsalesbill() {
        initComponents();
        Medium.edtsb=this;
        createpd();
       
        
    }
    public void drt()
    {
         jTableeditsalesbill.getColumn("Description").setWidth(0);
        jTableeditsalesbill.getColumn("Description").setMinWidth(0);
        jTableeditsalesbill.getColumn("Description").setMaxWidth(0);
    }
    public void tableinformation()
    {
        try
        {
            String productname=this.jTableeditsalesbill.getValueAt(jTableeditsalesbill.getSelectedRow(), 0).toString();
            String price=this.jTableeditsalesbill.getValueAt(jTableeditsalesbill.getSelectedRow(), 1).toString();
            String quantity=this.jTableeditsalesbill.getValueAt(jTableeditsalesbill.getSelectedRow(), 2).toString();
            String descountrate=this.jTableeditsalesbill.getValueAt(jTableeditsalesbill.getSelectedRow(), 3).toString();
            String description=this.jTableeditsalesbill.getValueAt(jTableeditsalesbill.getSelectedRow(), 4).toString();
            this.jComboBoxprn.setSelectedItem(productname);
            this.jTextFieldprice.setText(price);
            this.jTextFieldquantity.setText(quantity);
            this.jTextFielddcountrate.setText(descountrate);
            this.jTextAreadescription.setText(description);
            
        }
        catch(Exception ex)
        {
            System.out.println(ex);
        }
    }
    public void createpd()
    {
        Product pd=new Product();
        pdl=pd.Vectorproduct();
        DefaultComboBoxModel dc=new DefaultComboBoxModel();
        for(Product pdd:pdl)
        {
            dc.addElement(pdd.getProductName());
            jComboBoxprn.setModel(dc);
            
        }
    }
    public void Createdetailsalesbill()
    {
        try
        {
           Vector<String> cols =new Vector<String>();
          // cols.add("Billid");
           cols.add("ProductName");
           cols.add("Price");
           cols.add("Quantity");
           cols.add("DiscountRate");
           cols.add("Description");
           DetailSalesBill dt=new DetailSalesBill();
           DefaultTableModel dc=new DefaultTableModel(dt.lisdetailsalesbill(),cols);
           jTableeditsalesbill.setModel(dc);
        }
        catch(Exception ex)
        {
            System.out.println(ex);
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableeditsalesbill = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jPanel8 = new javax.swing.JPanel();
        jPanel14 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jPanel15 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel9 = new javax.swing.JPanel();
        jPanel18 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel19 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jPanel10 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        jPanel16 = new javax.swing.JPanel();
        jComboBoxprn = new javax.swing.JComboBox();
        jPanel17 = new javax.swing.JPanel();
        jTextFieldprice = new javax.swing.JTextField();
        jPanel12 = new javax.swing.JPanel();
        jPanel20 = new javax.swing.JPanel();
        jTextFieldquantity = new javax.swing.JTextField();
        jPanel21 = new javax.swing.JPanel();
        jPanel22 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel23 = new javax.swing.JPanel();
        jTextFielddcountrate = new javax.swing.JTextField();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextAreadescription = new javax.swing.JTextArea();
        jPanel5 = new javax.swing.JPanel();
        jPanel24 = new javax.swing.JPanel();
        jPanel25 = new javax.swing.JPanel();
        jPanel26 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jPanel27 = new javax.swing.JPanel();
        jPanel28 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jPanel29 = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(600, 220));

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(300, 172));
        jPanel1.setLayout(new java.awt.BorderLayout());

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(callcenter.CallcenterApp.class).getContext().getResourceMap(JInternalFrameeditdetailsalesbill.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jPanel1.add(jLabel1, java.awt.BorderLayout.PAGE_START);

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setPreferredSize(new java.awt.Dimension(458, 402));
        jPanel3.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTableeditsalesbill.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTableeditsalesbill.setName("jTableeditsalesbill"); // NOI18N
        jTableeditsalesbill.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableeditsalesbillMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTableeditsalesbill);

        jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel3, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel1, java.awt.BorderLayout.LINE_START);

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setPreferredSize(new java.awt.Dimension(230, 172));
        jPanel2.setLayout(new java.awt.BorderLayout());

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setPreferredSize(new java.awt.Dimension(236, 149));
        jPanel4.setLayout(new java.awt.BorderLayout());

        jPanel6.setName("jPanel6"); // NOI18N
        jPanel6.setPreferredSize(new java.awt.Dimension(80, 149));
        jPanel6.setLayout(new java.awt.GridLayout(3, 1, 3, 3));

        jPanel8.setName("jPanel8"); // NOI18N
        jPanel8.setLayout(new java.awt.GridLayout(2, 1, 2, 2));

        jPanel14.setName("jPanel14"); // NOI18N
        jPanel14.setLayout(new java.awt.BorderLayout());

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N
        jPanel14.add(jLabel3, java.awt.BorderLayout.CENTER);

        jPanel8.add(jPanel14);

        jPanel15.setName("jPanel15"); // NOI18N
        jPanel15.setLayout(new java.awt.BorderLayout());

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel15.add(jLabel2, java.awt.BorderLayout.CENTER);

        jPanel8.add(jPanel15);

        jPanel6.add(jPanel8);

        jPanel9.setName("jPanel9"); // NOI18N
        jPanel9.setLayout(new java.awt.GridLayout(2, 1, 2, 2));

        jPanel18.setName("jPanel18"); // NOI18N
        jPanel18.setLayout(new java.awt.BorderLayout());

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N
        jPanel18.add(jLabel4, java.awt.BorderLayout.CENTER);

        jPanel9.add(jPanel18);

        jPanel19.setName("jPanel19"); // NOI18N
        jPanel19.setLayout(new java.awt.BorderLayout());

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jPanel19.add(jLabel5, java.awt.BorderLayout.CENTER);

        jPanel9.add(jPanel19);

        jPanel6.add(jPanel9);

        jPanel10.setName("jPanel10"); // NOI18N
        jPanel10.setLayout(new java.awt.BorderLayout());

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        jPanel10.add(jLabel7, java.awt.BorderLayout.PAGE_START);

        jPanel6.add(jPanel10);

        jPanel4.add(jPanel6, java.awt.BorderLayout.LINE_START);

        jPanel7.setName("jPanel7"); // NOI18N
        jPanel7.setLayout(new java.awt.GridLayout(3, 1, 3, 3));

        jPanel11.setName("jPanel11"); // NOI18N
        jPanel11.setLayout(new java.awt.GridLayout(2, 1, 2, 2));

        jPanel16.setName("jPanel16"); // NOI18N
        jPanel16.setLayout(new java.awt.BorderLayout());

        jComboBoxprn.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBoxprn.setName("jComboBoxprn"); // NOI18N
        jPanel16.add(jComboBoxprn, java.awt.BorderLayout.CENTER);

        jPanel11.add(jPanel16);

        jPanel17.setName("jPanel17"); // NOI18N
        jPanel17.setLayout(new java.awt.BorderLayout());

        jTextFieldprice.setText(resourceMap.getString("jTextFieldprice.text")); // NOI18N
        jTextFieldprice.setName("jTextFieldprice"); // NOI18N
        jPanel17.add(jTextFieldprice, java.awt.BorderLayout.CENTER);

        jPanel11.add(jPanel17);

        jPanel7.add(jPanel11);

        jPanel12.setName("jPanel12"); // NOI18N
        jPanel12.setLayout(new java.awt.GridLayout(2, 1, 2, 2));

        jPanel20.setName("jPanel20"); // NOI18N
        jPanel20.setLayout(new java.awt.BorderLayout());

        jTextFieldquantity.setText(resourceMap.getString("jTextFieldquantity.text")); // NOI18N
        jTextFieldquantity.setName("jTextFieldquantity"); // NOI18N
        jPanel20.add(jTextFieldquantity, java.awt.BorderLayout.CENTER);

        jPanel12.add(jPanel20);

        jPanel21.setName("jPanel21"); // NOI18N
        jPanel21.setLayout(new java.awt.BorderLayout());

        jPanel22.setName("jPanel22"); // NOI18N
        jPanel22.setPreferredSize(new java.awt.Dimension(30, 22));
        jPanel22.setLayout(new java.awt.BorderLayout());

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N
        jPanel22.add(jLabel6, java.awt.BorderLayout.CENTER);

        jPanel21.add(jPanel22, java.awt.BorderLayout.LINE_END);

        jPanel23.setName("jPanel23"); // NOI18N
        jPanel23.setLayout(new java.awt.BorderLayout());

        jTextFielddcountrate.setText(resourceMap.getString("jTextFielddcountrate.text")); // NOI18N
        jTextFielddcountrate.setName("jTextFielddcountrate"); // NOI18N
        jPanel23.add(jTextFielddcountrate, java.awt.BorderLayout.CENTER);

        jPanel21.add(jPanel23, java.awt.BorderLayout.CENTER);

        jPanel12.add(jPanel21);

        jPanel7.add(jPanel12);

        jPanel13.setName("jPanel13"); // NOI18N
        jPanel13.setLayout(new java.awt.BorderLayout());

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTextAreadescription.setColumns(20);
        jTextAreadescription.setRows(5);
        jTextAreadescription.setName("jTextAreadescription"); // NOI18N
        jScrollPane2.setViewportView(jTextAreadescription);

        jPanel13.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jPanel7.add(jPanel13);

        jPanel4.add(jPanel7, java.awt.BorderLayout.CENTER);

        jPanel2.add(jPanel4, java.awt.BorderLayout.PAGE_START);

        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setPreferredSize(new java.awt.Dimension(236, 23));
        jPanel5.setLayout(new java.awt.BorderLayout());

        jPanel24.setName("jPanel24"); // NOI18N
        jPanel24.setPreferredSize(new java.awt.Dimension(80, 23));

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 80, Short.MAX_VALUE)
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 23, Short.MAX_VALUE)
        );

        jPanel5.add(jPanel24, java.awt.BorderLayout.LINE_START);

        jPanel25.setName("jPanel25"); // NOI18N
        jPanel25.setLayout(new java.awt.BorderLayout());

        jPanel26.setName("jPanel26"); // NOI18N
        jPanel26.setPreferredSize(new java.awt.Dimension(60, 23));
        jPanel26.setLayout(new java.awt.BorderLayout());

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jPanel26.add(jButton1, java.awt.BorderLayout.CENTER);

        jPanel25.add(jPanel26, java.awt.BorderLayout.LINE_START);

        jPanel27.setName("jPanel27"); // NOI18N
        jPanel27.setLayout(new java.awt.BorderLayout());

        jPanel28.setName("jPanel28"); // NOI18N
        jPanel28.setPreferredSize(new java.awt.Dimension(64, 23));
        jPanel28.setLayout(new java.awt.BorderLayout());

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N
        jPanel28.add(jButton2, java.awt.BorderLayout.CENTER);

        jPanel27.add(jPanel28, java.awt.BorderLayout.LINE_START);

        jPanel29.setName("jPanel29"); // NOI18N
        jPanel29.setLayout(new java.awt.BorderLayout());

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N
        jPanel29.add(jButton3, java.awt.BorderLayout.CENTER);

        jPanel27.add(jPanel29, java.awt.BorderLayout.CENTER);

        jPanel25.add(jPanel27, java.awt.BorderLayout.CENTER);

        jPanel5.add(jPanel25, java.awt.BorderLayout.CENTER);

        jPanel2.add(jPanel5, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTableeditsalesbillMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableeditsalesbillMouseClicked
        tableinformation();
}//GEN-LAST:event_jTableeditsalesbillMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JComboBox jComboBoxprn;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel26;
    private javax.swing.JPanel jPanel27;
    private javax.swing.JPanel jPanel28;
    private javax.swing.JPanel jPanel29;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableeditsalesbill;
    private javax.swing.JTextArea jTextAreadescription;
    private javax.swing.JTextField jTextFielddcountrate;
    private javax.swing.JTextField jTextFieldprice;
    private javax.swing.JTextField jTextFieldquantity;
    // End of variables declaration//GEN-END:variables
}
